import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        sc.nextLine();
        for(int i=0;i<n;i++){
            if(i>0){
                System.out.println();
            }
            String str=sc.nextLine();
            System.out.print(str.charAt(0));
            System.out.print(str.length()-2);
            System.out.print(str.charAt(str.length()-1));
        }
    }
    public static void main2(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        Stack<Integer> stack=new Stack<>();
        int cur=n;
        while(cur!=0){
            stack.push(cur%7);
            cur/=7;
        }
        while(!stack.empty()){
            System.out.print(stack.pop());
        }
        System.out.println();
    }
    public static void main1(String[] args) {
        Scanner sc = new Scanner(System.in);
        long l = sc.nextLong();
        long r = sc.nextLong();
        long count=func(l,r,3)+func(l,r,5)+func(l,r,7)-func(l,r,15)-func(l,r,21)-func(l,r,35)+func(l,r,105);
        System.out.println(count);
    }
    public static long func(long l,long r,long d){
        long count1=r/d;
        long count2=(l-1)/d;
        return count1-count2;
    }
}